package com.typy.www.tpay.ui.itemview;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.typy.www.tpay.R;
import com.typy.www.tpay.bean.vm.ActivicationVm;
import com.typy.www.tpay.bean.vm.NoticeVm;
import com.typy.www.tpay.ui.acitivity.WebActivity;
import com.typy.www.tpay.util.Logutil;
import com.typy.www.tpay.util.UpdataUiUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 13799 on 2018/6/15.
 */

public class NoticeItemView {

    View mView;
    ViewHolder holder;
    private Context mContext;

    public NoticeItemView(Context context) {
        mContext=context;
        mView = LayoutInflater.from(context).inflate(R.layout.item_notice, null);
        holder = new ViewHolder(mView);
    }

    public View getView() {
        return mView;
    }

    public void bind(final NoticeVm vm, final int position) {

        UpdataUiUtil.getDefaul().setText(vm.getFdTitle(),holder.tvContent).setText(vm.getFdCreateTime(),holder.tvTime);
        holder.llRoot.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                WebActivity.show(mContext,"公告",vm.getFdUrl());
            }
        });

    } public void bind(final ActivicationVm vm, final int position) {

        UpdataUiUtil.getDefaul().setText(vm.getFdRemark(),holder.tvContent)
                .setText(vm.getFdCreateTime(),holder.tvTime);
        holder.llRoot.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                WebActivity.show(mContext,"回复详情",vm.getFdUrl());
            }
        });

    }

    static class ViewHolder {
        @BindView(R.id.tv_content)
        TextView tvContent;
        @BindView(R.id.tv_time)
        TextView tvTime;
        @BindView(R.id.ll_root)
        LinearLayout llRoot;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
